//
//  PBMySeriveCell.m
//  PBHomeDemo
//
//  Created by Playboy on 2018/5/12.
//  Copyright © 2018年 tmkj. All rights reserved.
//

#import "PBMySeriveCell.h"

@interface PBMySeriveCell ()
@property (weak, nonatomic) IBOutlet UILabel *typeLabel;
@property (weak, nonatomic) IBOutlet UILabel *timeLabel;
@property (weak, nonatomic) IBOutlet UIImageView *coverImageView;
@property (weak, nonatomic) IBOutlet UILabel *nameLabel;
@property (weak, nonatomic) IBOutlet UILabel *phoneLabel;
@property (weak, nonatomic) IBOutlet UILabel *statesLabel;

@end

@implementation PBMySeriveCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

- (void)refreshWithModel:(PBMySeriveModel *)model {
    NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
    formatter.dateFormat = @"YYYY年MM月dd";
    // 数字时间戳转化为日期，如果为13位，则需要除以1000，或者去掉后3位
    NSDate *startDate = [NSDate dateWithTimeIntervalSince1970:[[model.insertTime substringWithRange:NSMakeRange(0, 10)] doubleValue]];
    NSString *startTime = [formatter stringFromDate:startDate];
    self.typeLabel.text = model.houseName;
    self.nameLabel.text = model.userName;
    self.phoneLabel.text = model.phone;
    self.timeLabel.text = startTime;
    if (model.imgs.count>0) {
        [self.coverImageView sd_setImageWithURL:[NSURL URLWithString:model.imgs[0][@"url"]] placeholderImage:nil];
    }
    if (model.status == 1) {
        self.statesLabel.text = @"待处理";
    }else if (model.status == 2){
        self.statesLabel.text = @"处理中";
    }else if (model.status == 3){
        self.statesLabel.text = @"已处理";
    }else if (model.status == 4){
        self.statesLabel.text = @"已撤销";
    }else if (model.status == 5){
        self.statesLabel.text = @"已拒绝";
    }
}

@end
